import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import { type PaginationProps } from "@pureadmin/table";

type resultAPI = {
  isSuccess?: boolean;
  msg?: string;
  pageInfo?: object;
  result?: Array<any>;
  onePage?: PaginationProps;
};

//获取应用集合
export const getAppList = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/getAppList"), {
    data
  });
};

//保存应用
export const saveApp = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/saveApp"), {
    data
  });
};

//删除应用
export const delApp = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/delApp"), {
    data
  });
};

//获取一个应用
export const getApp = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/getApp"), {
    params
  });
};

//获取角色列表
export const getRolesList = () => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getRolesList"),
    {}
  );
};

//获取一个应用配置对象
export const getAppConfig = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getAppConfig"),
    { params }
  );
};

//保存一个应用配置对象
export const saveAppConfig = (data?: object) => {
  console.log(data, "towDATA");
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/saveAppConfig"),
    { data }
  );
};

//删除一个应用模块
export const delModel = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/delModel"), {
    params
  });
};

//获取表视图字段
export const getTableFields = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getTableFields"),
    {
      params
    }
  );
};

//获取模板名称集合

export const getTemplateKey = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getTemplateKey"),
    {
      params
    }
  );
};

//获取一个模板对象
export const getTemplateCode = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getTemplateCode"),
    {
      params
    }
  );
};

//保存一个功能
export const saveAppFunction = (data?: object) => {
  console.log(data);
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/saveAppFunction"),
    {
      data
    }
  );
};
//删除一个功能要
export const delAppfun = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/delAppFunL"), {
    params
  });
};

//依据模块ID获取一个功能列表
export const getAppFunList = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/getFunList"), {
    data
  });
};

//添加新模块
export const addNewModel = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/addNewModel"),
    {
      params
    }
  );
};

//获取消息模板列表
export const getMsgTemList = () => {
  return http.request<resultAPI>(
    "get",
    baseUrlApi("Application/getMsgTempList"),
    {}
  );
};

//复制应用
export const copyApplication = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("Application/copyApp"), {
    params
  });
};

//保存一个看板
export const saveDataView = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/saveDataView"),
    {
      data
    }
  );
};

//获取一个看板
export const getDataView = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("Application/getDataView"),
    {
      params
    }
  );
};
//获取一个看板,普通用户
export const getDataViewByID = (params?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("DataView/getDataViewByAppID"),
    {
      params
    }
  );
};
